package com.study.common.base;

import com.study.common.constant.RegisterConstant;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author zhangbo
 * @包名称 com.study.common.base
 * @类描述 <pre>服务器注册信息对象</pre>
 * @作者 zhangbo
 * @创建时间 2020/5/31.
 * @版本 1.00
 * @修改记录 <pre>
 *     版本           修改人         修改日期         修改内容描述
 *     -----------------------------------------------------------
 *     1.00           zhangbo        2020/5/31.           类创建
 *     -----------------------------------------------------------
 * </pre>
 */
@Data
@NoArgsConstructor
@ToString
public class RegisterInfo implements Serializable {

    private static final long serialVersionUID = -1658990520094192402L;

    /*服务器IP地址*/
    private String serviceIp;
    /*服务器端口号*/
    private int servicePort;
    /*服务器版本号*/
    private String version;
    /*服务器权重*/
    private int weight;
    /*客户端连接数*/
    private int clientCount;
    /*客户端连接IP列表*/
    private Set<String> clientIpList;
    /*服务提供的方法列表*/
    private List<String> methodList;

    public RegisterInfo(String serviceIp, int servicePort) {
        this.serviceIp = serviceIp;
        this.servicePort = servicePort;
        this.version = RegisterConstant.DEFAULT_VERSION;
        this.weight = 1;
        this.clientCount = 0;
        this.clientIpList = new HashSet<>(8);
    }


    public RegisterInfo(String serviceIp, int servicePort, String version) {
        this.serviceIp = serviceIp;
        this.servicePort = servicePort;
        this.version = version;
        this.weight = 1;
        this.clientCount = 0;
        this.clientIpList = new HashSet<>(8);
    }

    public RegisterInfo(String serviceIp, int servicePort, int weight) {
        this.serviceIp = serviceIp;
        this.servicePort = servicePort;
        this.version = RegisterConstant.DEFAULT_VERSION;
        this.weight = weight;
        this.clientCount = 0;
        this.clientIpList = new HashSet<>(8);
    }


    public RegisterInfo(String serviceIp, int servicePort, String version, int weight) {
        this.serviceIp = serviceIp;
        this.servicePort = servicePort;
        this.version = version;
        this.weight = weight;
        this.clientCount = 0;
        this.clientIpList = new HashSet<>(8);
    }


}
